package com.lemontree.spring4.day05web;

import com.lemontree.spring4.day05web.cotroller.HomeController;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.web.servlet.MockMvc;

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup;

/**
 * @Author: YLBG-YCY-1325
 * @Description:
 * @Date: 2017/8/29
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = SpittrWebApplicationInitializer.class)
public class SpringTestConfig {

    @Test
    public void test() throws Exception {
        HomeController homeController = new HomeController();
        homeController.home();
        MockMvc mockMvc = standaloneSetup(homeController).build();
        mockMvc.perform(get("/")).andExpect(view().name("home"));
    }

    @Test
    public void test2(){
        System.out.println("1");
    }
}
